package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.Order;
import com.itheima.vo.OrderSuccessInfoVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface OrderMapper extends BaseMapper<Order> {

    @Select("select m.name as member,s.name as setmeal,date_format(order_date,'%Y-%m-%d') order_date from t_order o \n" +
            "LEFT JOIN t_member m ON m.id=o.member_id\n" +
            "LEFT JOIN t_setmeal s ON s.id=o.setmeal_id\n" +
            "where o.id=#{orderId}")
    OrderSuccessInfoVo orderSuccess(@Param("orderId") String orderId);

    @Select("select s.name,count(*) as value from t_order o \n" +
            "LEFT JOIN t_setmeal s ON o.setmeal_id=s.id   \n" +
            "GROUP BY s.id")
    List<Map> selectSetmealData();


}
